﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace GiaoXuLanTranh_MucVu.Models
{
    public static class Encrypt
    {
        // Methods
        public static string Encrypte(string text)
        {
            if (text == null)
            {
                return "";
            }
            return Hash(text, "SHA1");
        }

        private static string Hash(string text, string hashType)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(text);
            byte[] dst = new byte[bytes.Length];
            Buffer.BlockCopy(bytes, 0, dst, 0, bytes.Length);
            return Convert.ToBase64String(Hash(dst, hashType)).ToLower();
        }

        private static byte[] Hash(byte[] bytes, string hashType)
        {
            return HashAlgorithm.Create(hashType).ComputeHash(bytes);
        }
    }



}